<template>
  <div id="sub"></div>
</template>
<script lang="ts">
import { defineComponent, onBeforeUnmount, onMounted } from "vue";
import { loadMicroApp } from "qiankun";
import { getCache, getToken } from "@/utils/cache";
import { useRouter } from "vue-router";
export default defineComponent({
  setup() {
    let app: any = null;
    const router = useRouter();
    onMounted(() => {
      app = loadMicroApp({
        entry: import.meta.env.MODE === "development" ? "//localhost:8082" : "/child/ns-flowable/",
        name: "ns_flowable",
        container: "#sub",
        props: {
          Authorization: "Bearer " + getToken(),
          token: getCache("CacheTenantCode", { isParse: false }) || "",
          router
        }
      });
    });
    onBeforeUnmount(() => {
      if (app) {
        app.unmount();
      }
    });
  }
});
</script>
